<template>
    <div>
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item> <i class="el-icon-lx-calendar"></i> 消息管理 </el-breadcrumb-item>
                <el-breadcrumb-item>假条详情</el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="container">
            <div class="form-box">
                <el-form ref="form" :model="form" label-width="80px">
                    <el-divider content-position="left">假条详情</el-divider>

                    <el-form-item label="员工编号" prop="tid">
                        <el-input v-model="form.tid" disabled></el-input>
                    </el-form-item>
                    <el-form-item label="员工姓名" prop="name">
                        <el-input v-model="employee.name" disabled></el-input>
                    </el-form-item>

                    <el-form-item label="请假时间">
                        <el-date-picker
                            v-model="form.date"
                            type="daterange"
                            range-separator="至"
                            value-format="yyyy-MM-dd"
                            start-placeholder="开始日期"
                            end-placeholder="结束日期"
                            disabled
                            >
                        </el-date-picker>
                    </el-form-item>

                    <el-form-item label="审核人">
                        <el-input v-model="superior.name" disabled></el-input>
                    </el-form-item>

                    <el-form-item label="状态">
                        <el-tag>{{form.status=='00'?'未读':'已读'}}</el-tag>
                    </el-form-item>

                    <el-form-item label="进程">
                        <el-tag>{{leaveResult[form.result]}}</el-tag>
                    </el-form-item>

                       <el-form-item label="假条状态" prop="title">
                        <el-switch
                            style="display: block"
                            v-model="form.selfEnable"
                            active-color="#13ce66"
                            inactive-color="#ff4949"
                            active-value="01"
                            inactive-value="00"
                            active-text="正常"
                            inactive-text="已删除">
                        </el-switch>
                    </el-form-item>

                    
                    <el-form-item label="请假原因" prop="description">
                        <el-input type="textarea" rows="5" v-model="form.description" disabled></el-input>
                    </el-form-item>

                    <el-form-item>
                        <el-button @click="goback" icon="el-icon-arrow-left">返回</el-button>
                    </el-form-item>
                </el-form>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    name: 'baseform',
    inject: ['reload'],
    data() {
        return {
            id: this.$route.query.id,
            leaveResult:{},
            employee:{},
            superior:{},
            form: {
                tid:'',
                leader:'',
                date:[],
                startTime: '',
                endTime: '',
                status: '',
                result:'',
                description: ''
            }
        };
    },
    created: function () {
       this.init();
       this.getLeaveResult();
    },
    methods: {
        goback(){
            this.$router.go(-1);
        },

        async init(){
            var d = await this.$http.get("/leave/"+this.id)
            if(d.code==200){
                this.form=d.data
                this.form.date=[this.form.startTime,this.form.endTime]
                this.getEmployee(this.form.tid);
                this.getSuperior(this.form.leader)
                
            }
        },

        getLeaveResult(){
            this.leaveResult=JSON.parse(window.sessionStorage.getItem("leaveResult"))
        },

        async getSuperior(tid){
             var d = await this.$http.get("/employeetid/"+tid)
            if(d.code==200){
                this.superior=d.data
            }
        },

        async getEmployee(tid){
            var d = await this.$http.get("/employeetid/"+tid)
            if(d.code==200){
                this.employee=d.data
               
            }
        }
      
    }
};
</script>